Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x](backport #3935) Fix bad error handling in api key auth #3937

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 20, 2024

What is the problem this PR solves?

Currently any error returned back to Fleet Server from elasticsearch that is not 401 or 429 is returned as a 401 error. This tells the calling client that the API key is invalidate. That is only true when the error is 401, otherwise the error means something different.

How does this PR solve the problem?

This solves the issue by returning the actual error back elasticsearch to the calling client. This means that a 500 error from elasticsearch will not result in a 401 back to the client, instead it will be a 500 error.

This uses the standard es.ParseError logic to determine the error and return something readable to the calling client.

How to test this PR locally

  • Bootstrap Fleet Server
  • Turn-off elasticsearch
  • See that 401 is not returned to the client

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • [ ] I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected. (no effect on scale)
  • [ ] I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc. (no effect)

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

Related issues

* Fix bad error handling in api key auth.

* Don't return so much information.

* bug-fix

* Remove un-need changes.

(cherry picked from commit 28e96bf)
@mergify mergify bot requested a review from a team as a code owner September 20, 2024 16:58
@mergify mergify bot added the backport label Sep 20, 2024
@blakerouse blakerouse enabled auto-merge (squash) September 20, 2024 17:06
@blakerouse blakerouse merged commit dc11142 into 8.x Sep 20, 2024
7 of 8 checks passed
@blakerouse blakerouse deleted the mergify/bp/8.x/pr-3935 branch September 20, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant